package kr.pe.xissy.soulmate.domain;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import kr.pe.xissy.soulmate.security.role.UserGrantedAuthority;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class User extends SoulMateDomain implements UserDetails {

	private static final long serialVersionUID = 1731258663322381519L;

	@Autowired
	protected UserGrantedAuthority userGrantedAuthority;

	protected String email;
	protected String password;
	protected String nickName;

	public User() {
	}

	public User(String email) {
		this.email = email;
	}

	public User(String email, String password, String nickName) {
		this.email = email;
		this.password = password;
		this.nickName = nickName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public Collection<GrantedAuthority> getAuthorities() {
		Set<GrantedAuthority> grantedAuthoritySet = new HashSet<GrantedAuthority>();
		grantedAuthoritySet.add(new UserGrantedAuthority());

		return grantedAuthoritySet;
	}

	public String getUsername() {
		return email;
	}

	public boolean isAccountNonExpired() {
		return true;
	}

	public boolean isAccountNonLocked() {
		return true;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}

	public boolean isEnabled() {
		return true;
	}

}
